package com.wangzhenyu.learn.test.designPattern


//模板模式


@Suppress("UNUSED")
object NTemplatePattern {


    //抽象模板
    abstract class SoyMilk {

        fun make() {
            select()
            addCondiments()
            soak()
            beat()
        }

        protected open fun select() {
            println("选择优质大豆")
        }

        protected abstract fun addCondiments()

        protected open fun soak() {
            println("黄豆和配料开始浸泡")
        }

        protected open fun beat() {
            println("黄豆和配料打碎")
        }

    }

    //具体模板
    class ReadBeanSoyMilk : SoyMilk() {

        override fun addCondiments() {
            println("加入红豆")
        }

        override fun beat() {
            println("黄豆和红豆打碎")
        }
    }

    //具体模板
    class PeanutSoyMilk : SoyMilk() {

        override fun addCondiments() {
            println("加入花生")
        }
    }

}